<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>引导页</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>

    <style type="text/css">
        .startup-page {
            width: 100vw;
            height: 100vh;
        }

        .startup-page .startup,
        .startup-page .ad-picture {
            display: none;
            width: 100%;
            height: 100%;
        }

        .startup-page .swiper-container,
        .startup-page .swiper-container ul,
        .startup-page .swiper-container ul li {
            width: 100%;
            height: 100%;
            background-repeat: no-repeat!important;
            background-position: center center!important;
            background-size: cover!important;
        }

        .startup-page .swiper-container ul li {
            position: relative;
        }

        .startup-page .swiper-container ul li .to-login {
            position: absolute;
            left: 5%;
            width: 90%;
            bottom: 1rem;
            height: 0.85rem;
            background: #ff7777;
            border-radius: 3px;
            color: #ffffff;
            font-size: 0.3rem;
            text-align: center;
            line-height: 0.85rem;
        }

        .startup-page .swiper-container ul li .to-login:active {
            background: #ff9786;
        }

        .startup-page .ad-picture {
            width: 100%;
            height: 100%;
            background-size: 100% 100% !important;
            position: relative;
        }

        .startup-page .ad-picture .jump {
            display: inline-block;
            padding: 0 0.2rem;
            line-height: 0.48rem;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 0.4rem;
            font-size: 0.26rem;
            color: #fff;
            position: absolute;
            right: 0.4rem;
            bottom: 1.5rem;
            z-index: 9999;
            /*border: 1px #e2e2e2 solid;*/
        }
    </style>
</head>

<body>
<div class="startup-page">
    <div class="startup">
        <div class="swiper-container " id="startup">
            <ul class="swiper-wrapper" id="guidePic">
                <!--<li class="swiper-slide" style="background: url(../../image/g1.png)"></li>
                <li class="swiper-slide" style="background: url(../../image/g2.png)"></li>
                <li class="swiper-slide" style="background: url(../../image/g3.png)"></li>
                <li class="swiper-slide" style="background: url(../../image/g4.png)"><div class="to-login" tapmode onclick="toLogin()">打开Bubble</div></li>-->
            </ul>
        </div>
    </div>
    <div class="ad-picture" id="ad">
        <div class="jump" id="jumpToIndex">跳过 8s</div>
        <div class="swiper-container" id="adPic">
            <ul class="swiper-wrapper" id="adPicHtml">
                <!--<li class="swiper-slide" style="background: url(../../image/g1.png)"></li>
                <li class="swiper-slide" style="background: url(../../image/g2.png)"></li>
                <li class="swiper-slide" style="background: url(../../image/g3.png)"></li>
                <li class="swiper-slide" style="background: url(../../image/g4.png)"><div class="to-login" tapmode onclick="toLogin()">打开Bubble</div></li>-->
                <!--<li class="swiper-slide" style="background: url(http://bingge.59156.cn/uploads/picture/2019-11-20/5dd4a3aae2f0b.png)"></li><li class="swiper-slide" style="background: url(http://bingge.59156.cn/uploads/picture/2019-11-20/5dd4a384f1886.png)"></li>-->
            </ul>
        </div>
    </div>
</div>


<section class="mask_pop">
    <div class="mask"></div>
    <div class="msg_pop2 pop pb20" style="display: none; max-width: calc(100% - 1.8rem);">
        <div class="msg_pop_title">个人信息保护指引</div>
        <div class="msg_pop_content" style="text-align: left; padding: 0 0.3rem 0.4rem;">请你务必审慎阅读、充分理解“用户协议”和“隐私政策”各条款，包括但不限于：为了向你提供内容分享等服务，我们需要收集你的设备信息、操作日志等个人信息。你可以在“手机设置”中查看、变更、删除个人信息并管理你的授权。你可阅读<a href="javascript:void(0);" class="c-primary" tapmode onclick="commonUrl('../member/xieyi')">《用户协议》</a>和<a href="javascript:void(0);" class="c-primary" tapmode onclick="commonUrl('../member/yinsizhengce')">《隐私政策》</a>了解详细信息。<br>
            如你同意，请点击”同意“开始接受我们的服务</div>
        <div class="flex_center pb20">
            <div class="btn7 mr30" onclick="popClose();">关闭</div>
            <div class="btn6" onclick="popClose();">同意</div>
        </div>
    </div>
</section>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    apiready = function () {
        // setFixStatusBar(); //设置状态栏


        $(".startup-page").height($(window).height() - $("#header").outerHeight(true));

        var deviceId = $api.getStorage('deviceId');
        if (isDefine(deviceId)) {
            getAdPage();//获取广告
        } else {
            getBootPage(); //获取引导页
            var tel_uniquid = api.deviceId;
            $api.setStorage('deviceId', tel_uniquid)

            openApp()
        }


    };

    function openApp() {
        $(".mask").show();
        $(".mask_pop").addClass("on");
        $(".msg_pop2").show();
    }

    function popClose() {
        $(".mask").hide();
        $(".mask_pop").removeClass("on");
    }

    var swiper = new Swiper('#startup', {
        observer: true,
        observeParents: true,
    });
    var swiper1 = new Swiper('#adPic', {
        observer: true,
        observeParents: true,
    });


    //获取引导页
    function getBootPage() {
        var type = {type: 1};
        getAjax(Interface.get_guide, type, function (res) {
            clearInterval(t);
            var data = res.data;
            if (isDefine(data)) {
                $(".startup").show();
                var guideHtml = '';
                for (var i = 0; i < data.length; i++) {
                    if (i == (data.length - 1)) {
                        guideHtml += '<li class="swiper-slide" style="background: url(' + ajaxUrl + data[i].icon_path + ')"><div class="to-login" tapmode onclick="toLogin()">进入情报局</div></li>'
                    } else {
                        guideHtml += '<li class="swiper-slide" style="background: url(' + ajaxUrl + data[i].icon_path + ')"></li>'
                    }
                }
                $("#guidePic").html(guideHtml)
            } else {
                api.openWin({
                    name: 'login_pwd',
                    url: '../login/login_pwd.html',
                    slidBackEnabled: false,
                    allowEdit: true,
                    pageParam: {}
                });
            }
        }, function (error) {

        })
    }

    //获取广告
    function getAdPage() {

        var type = {type: 2};
        getAjax(Interface.get_guide, type, function (res) {

            var data = res.data;
            // data = {"status":200,
            // "token":"","data":
            //           [{"id":21,"icon":9739,"status":1,"icon_path":"/static/api/image/logo.png","type":2,"create_time":1582947578,"update_time":1582947952}],
            //   "msg":"请求成功"
            // }
            if (isDefine(data)) {
              console.log(jsonChange(data))

                $(".ad-picture").show();
                var adHtml = '';
                for (var i = 0; i < data.length; i++) {
                    adHtml += '<li class="swiper-slide" style="background: url(' + ajaxUrl + data[i].icon_path + ')"></li>'
                }
                console.log(adHtml)
                $("#adPicHtml").html(adHtml)
            }else {
                checkToken()
            }
        }, function (error) {

        })
    }

    //进入登录页
    function toLogin() {
        api.openWin({
            name: 'login_pwd',
            url: '../login/login_pwd.html',
            slidBackEnabled: false,
            allowEdit: true,
            pageParam: {}
        });
        setTimeout(function () {
            api.closeWin();
        },500)

    }

    //检测token
    function checkToken() {
        var token = $api.getStorage('token');
        var userInfo = $api.getStorage('userInfo');
        var tokenStatus = 0;
        if(isDefine(userInfo)){
           tokenStatus = $api.getStorage('userInfo').status;
        }
        if (isDefine(token) && tokenStatus != 2) {
            api.openWin({
                name: 'index',
                url: '../index/index.html',
                slidBackEnabled: false,
                allowEdit: true,
                pageParam: {}
            });
            clearInterval(t);
        } else {
            api.openWin({
                name: 'login_pwd',
                url: '../login/login_pwd.html',
                slidBackEnabled: false,
                allowEdit: true,
                pageParam: {}
            });
            clearInterval(t);
        }
    }


    var time = 6;
    //获取验证码倒计时
    var jump = $("#jumpToIndex");//跳过按钮
    var t = setInterval(function () {
        time--;
        jump.html("跳过 " + time + 's');
        if (time == 0) {
            clearInterval(t);
            checkToken();
        }
    }, 1000);
    jump.click(function () {
        clearInterval(t);
        checkToken();
    });


</script>
